package cn.stylefeng.guns.modular.ry600.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.stylefeng.guns.modular.system.model.Bindclient;
import cn.stylefeng.guns.modular.system.model.Clientcustomer;
import cn.stylefeng.guns.modular.system.dao.BindclientMapper;
import cn.stylefeng.guns.modular.ry600.service.IBindclientService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2018-12-24
 */
@Service
public class BindclientServiceImpl extends ServiceImpl<BindclientMapper, Bindclient> implements IBindclientService {
	@Autowired
	private BindclientMapper bindclientMapper;
	@Override
//	@DataSource(name = "#dataSource")
	public Object selectByMsg(Map<String, Object> msg) {
		// TODO Auto-generated method stub
		return bindclientMapper.selectByMsg(msg);
	}
	@Override
	@DataSource(name = "#dataSource")
	public int insertBatch(List<Bindclient> bindclient,
			String dataSource) {
		for (int i = 0; i < bindclient.size(); i++) {
			this.insert(bindclient.get(i));
		}
		return 0;
	}
	@Override
	@DataSource(name = "#dataSource")
	public void deletes(Integer bindclientId, String dataSource) {
		// TODO Auto-generated method stub
		this.deleteById(bindclientId);
	}
	@Override
	@DataSource(name = "#dataSource")
	public int delByDao(Bindclient bindclient, String dataSource) {
		// TODO Auto-generated method stub
		return bindclientMapper.delByDao(bindclient);
	}
	@Override
	@DataSource(name = "#dataSource")
	public int insByDao(Bindclient bindclient, String dataSource) {
		// TODO Auto-generated method stub
		Map<String,Object> msg=new HashMap<String,Object>();
		msg.put("clientId", bindclient.getClientId());
		//msg.put("bindclientId", bindclient.getBindclientId());
		List<Bindclient> bindclientl=bindclientMapper.selectByMsg(msg);
		if(bindclientl.size()==0){
			bindclientMapper.insByDao(bindclient);
		}
		return 0;
	}
	@Override
	@DataSource(name = "#dataSource")
	public int delByDaos(List<Bindclient> bindclients, String dataSource) {
		for(int i=0;i<bindclients.size();i++){
			bindclientMapper.delByDao(bindclients.get(i));
		}
		return 0;
	}

}
